package com.jxcq.tensquare.qa.dao;

import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;

import com.jxcq.tensquare.qa.pojo.Problem;
import org.springframework.data.jpa.repository.Query;

/**
 * 数据访问接口
 * @author Administrator
 *
 */
public interface ProblemDao extends JpaRepository<Problem,String>,JpaSpecificationExecutor<Problem>{

    @Query(value = "SELECT * FROM tb_problem pro ,tb_pl pl WHERE pro.id = pl.problemid AND pl.labelid=? ORDER BY pro.replytime DESC",nativeQuery = true)
    Page<Problem> newlist(String labelid, Pageable pageable);

    @Query(value = "SELECT * FROM tb_problem pro ,tb_pl pl WHERE pro.id = pl.problemid AND pl.labelid=? ORDER BY pro.reply DESC",nativeQuery = true)
    Page<Problem> hotlist(String labelid, Pageable pageable);

    @Query(value = "SELECT * FROM tb_problem pro ,tb_pl pl WHERE pro.id = pl.problemid AND pl.labelid=? AND pro.reply = '0' ORDER BY pro.createtime DESC",nativeQuery = true)
    Page<Problem> waitlist(String labelid, Pageable pageable);
	
}
